#ifndef __M_MENU_H__
#define __M_MENU_H__

#include <psp2common/types.h>
#include <psp2kern/ctrl.h>

enum MenuItemTypes
{
    OPTION_TYPE_NONE,
    OPTION_TYPE_CALLBACK,
    OPTION_TYPE_MENU,
    OPTION_TYPE_STR,
    OPTION_TYPE_STR_ARRAY,
    OPTION_TYPE_INT,
    OPTION_TYPE_INT_ARRAY,
    OPTION_TYPE_INT_STEP,
    OPTION_TYPE_CB_VOID,
};

typedef struct StrOption
{
    char *name;
    uint32_t color;
} StrOption;

typedef struct StrArrayOption
{
    char **names;
    int n_names;
    uint32_t color;
} StrArrayOption;

typedef struct IntOption
{
    int *value;
    char *format;
    uint32_t color;
} IntOption;

typedef struct IntArrayOption
{
    int *values;
    int n_values;
    char *format;
    uint32_t color;
} IntArrayOption;

typedef struct IntStepOption
{
    int min;
    int max;
    int step;
    char *format;
    uint32_t color;
} IntStepOption;

typedef struct CbVoidOption
{
    int (*callback)();
    int option_type;
    void *option;
} CbVoidOption;

typedef struct OptionMenuItem
{
    char *name;
    int type;
    uint32_t color;
    int32_t *value;
    void *option;
    int option_changed;
} OptionMenuItem;

typedef struct OptionMenu
{
    char *title;
    OptionMenuItem *items;
    int n_items;
    struct OptionMenu *parent;
    uint8_t read_only;
    uint8_t move_loop;
    int top_pos;
    int focus_pos;
} OptionMenu;

int getMenuWindowWidth();
int getMenuWindowHeight();

void updateMenuOptions();

int isShowingMenu();
int openMenu();
int closeMenu();
void drawMenu();
void ctrlMenu();

extern int g_cpu_clock_values[], g_bus_clock_values[];
extern int g_gpu_clock_values[], g_xbr_clock_values[];

#endif